import request from '@/utils/request'
import type { DynamicPage, DynamicType } from '@/api/types/dynamic'

export const add = (data: { content: string, status: string, top: boolean }) => {
  return request<boolean>({
    method: 'post',
    url: '/admin/dynamic',
    data
  })
}

export const pageList = (params: DynamicType) => {
  return request<DynamicPage>({
    method: 'get',
    url: '/admin/dynamic/page',
    params
  })
}

export const updateStatus = (id: number, status: string) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/dynamic/' + id + "/" + status
  })
}

export const deleteById = (id: number) => {
  return request<DynamicPage>({
    method: 'delete',
    url: '/admin/dynamic/' + id
  })
}

export const changeTop = (id: number, status: boolean) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/dynamic/top/' + id + "/" + status
  })
}